/*
 * IControleView.java
 */
package icontrole;

import icontrole.core.Centro;
import icontrole.core.Export;
import icontrole.core.Ponto;
import icontrole.core.ServerQuanser;
import icontrole.quanserclient.QuanserConfig;
import java.util.Observable;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Observer;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import icontrole.core.Plot;
import icontrole.exp_one.Util;
import java.awt.Color;
import org.jfree.data.xy.XYSeries;

/**
 * The application's main frame.
 */
public class IControleView extends FrameView implements Observer {

    private QuanserConfig _quanserconfig;
    private ServerQuanser _server;
    private Centro _centro;
    private Util _util;
    private int _line;
    private boolean state;
    private int selectedIndex;
    public Export _export;
    private int count;
    private XYSeries _xytank_I;
    private XYSeries _xytank_II;
    private XYSeries _xyerro;
    private XYSeries _xyscontrol;

    private void LoadCharts() {
        _xyerro = new XYSeries("Erro");
        _xyscontrol = new XYSeries("Sinal de Controle");
        _xytank_I = new XYSeries("Tank - I");
        _xytank_II = new XYSeries("Tank - II");
        ((Plot) _plotALL).AddSeries(_xyerro, Color.black);
        ((Plot) _plotALL).AddSeries(_xyscontrol, Color.orange);
        ((Plot) _plotALL).AddSeries(_xytank_I, Color.red);
        ((Plot) _plotALL).AddSeries(_xytank_II, Color.green);
        ((Plot) _plotALL).AddSpace("Tempo", "Nivel");
        ((Plot) _plotALL).Loading("Geral", true);
        ((Plot) ChartOne).AddSeries(_xytank_I, Color.red);
        ((Plot) ChartOne).AddSpace("Tempo", "Nivel");
        ((Plot) ChartOne).Loading("Tank - I", false);
        ((Plot) ChartTwo).AddSeries(_xytank_II, Color.green);
        ((Plot) ChartTwo).AddSpace("Tempo", "Nivel");
        ((Plot) ChartTwo).Loading("Tank - II", false);
        ((Plot) ChartSControle).AddSeries(_xyscontrol, Color.orange);
        ((Plot) ChartSControle).AddSpace("Tempo", "Nivel");
        ((Plot) ChartSControle).Loading("Sinal de Controle", false);
        ((Plot) ChartErro).AddSeries(_xyerro, Color.black);
        ((Plot) ChartErro).AddSpace("Tempo", "Nivel");
        ((Plot) ChartErro).Loading("Erro", false);

    }

    private void Load() {

        this._util = new Util();
        this._export = new Export();
        this._export.Load();
        this._server = this._export.getServer();
        this._server.setIp("127.0.0.1");
        this._server.setPort("20081");
        this._server.setConstank1(5.88);
        this._server.setConstank2(5.88);
        this._centro = new Centro(this._server);
        this._quanserconfig = new QuanserConfig(this);
        this._server.addObserver(this);
        this.count = 0;
        this._line = 0;
        this.LabelConst_I.setText(this._server.getConstank1().toString());

        LoadCharts();
    }

    public IControleView(SingleFrameApplication app) {
        super(app);

        initComponents();
        this.Load();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = IControleApp.getApplication().getMainFrame();
            aboutBox = new IControleAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        IControleApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        DesktopHome = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        LabelNivel = new javax.swing.JLabel();
        SlideNivel = new javax.swing.JSlider();
        jPanel2 = new javax.swing.JPanel();
        ProgTank_I = new javax.swing.JProgressBar();
        LabelTank_I = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        LabelTank_II = new javax.swing.JLabel();
        ProgTank_II = new javax.swing.JProgressBar();
        jPanel5 = new javax.swing.JPanel();
        ButtIniciar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        ButtonAtualizar = new javax.swing.JButton();
        JTabControle = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        ComboTank = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        ComboControlador = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        JText_P = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        JText_I = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        JText_D = new javax.swing.JTextField();
        Combo_I = new javax.swing.JComboBox();
        Combo_D = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        LabelSobresinal = new javax.swing.JLabel();
        LabelTempoDePico = new javax.swing.JLabel();
        RadioCondicional = new javax.swing.JRadioButton();
        jLabel11 = new javax.swing.JLabel();
        LabelTempSubida = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        LabelTempAcomodacao = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        const_k0 = new javax.swing.JTextField();
        const_k1 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        const_ki = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel7 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        Ad_a00 = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        Ad_a01 = new javax.swing.JTextField();
        Ad_a10 = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        Ad_a11 = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        Bd_b0 = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        Bd_b1 = new javax.swing.JTextField();
        jPanel11 = new javax.swing.JPanel();
        L_l0 = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        L_l1 = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        LabelTensao = new javax.swing.JLabel();
        SlideTensao = new javax.swing.JSlider();
        jScrollPane1 = new javax.swing.JScrollPane();
        TableTT = new javax.swing.JTable();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        LabelConst_I = new javax.swing.JLabel();
        _plotALL = new Plot();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        ChartTank_I = new javax.swing.JPanel();
        ChartOne = new Plot();
        ChartTank_II = new javax.swing.JPanel();
        ChartTwo = new Plot();
        ChartSinalControle = new javax.swing.JPanel();
        ChartSControle = new Plot();
        jPanel9 = new javax.swing.JPanel();
        ChartErro = new Plot();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        Button_Abrir = new javax.swing.JMenuItem();
        ButtonSalvar = new javax.swing.JMenuItem();
        Button_Salvar = new javax.swing.JMenuItem();
        ButtonPrint = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        MenuExp = new javax.swing.JMenu();
        MenuConfig = new javax.swing.JMenu();
        ButtonQuanser = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();

        mainPanel.setBackground(new java.awt.Color(255, 255, 255));
        mainPanel.setMaximumSize(new java.awt.Dimension(600, 600));
        mainPanel.setName("mainPanel"); // NOI18N

        DesktopHome.setBackground(new java.awt.Color(255, 255, 255));
        DesktopHome.setMaximumSize(new java.awt.Dimension(3000, 3000));
        DesktopHome.setMinimumSize(new java.awt.Dimension(1024, 768));
        DesktopHome.setName("DesktopHome"); // NOI18N
        DesktopHome.setPreferredSize(null);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Nivel (cm)"));
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new java.awt.GridLayout(1, 0));

        LabelNivel.setFont(new java.awt.Font("Tahoma", 1, 18));
        LabelNivel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabelNivel.setText("10");
        LabelNivel.setName("LabelNivel"); // NOI18N
        jPanel1.add(LabelNivel);

        SlideNivel.setBackground(new java.awt.Color(255, 255, 255));
        SlideNivel.setMaximum(30);
        SlideNivel.setOrientation(javax.swing.JSlider.VERTICAL);
        SlideNivel.setPaintTicks(true);
        SlideNivel.setValue(10);
        SlideNivel.setName("SlideNivel"); // NOI18N
        SlideNivel.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SlideNivelStateChanged(evt);
            }
        });
        jPanel1.add(SlideNivel);

        jPanel1.setBounds(10, 10, 74, 180);
        DesktopHome.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Sensor - Tk(I)"));
        jPanel2.setName("jPanel2"); // NOI18N

        ProgTank_I.setMaximum(30);
        ProgTank_I.setOrientation(1);
        ProgTank_I.setValue(15);
        ProgTank_I.setName("ProgTank_I"); // NOI18N

        LabelTank_I.setFont(new java.awt.Font("Tahoma", 1, 18));
        LabelTank_I.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabelTank_I.setText("3.12");
        LabelTank_I.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        LabelTank_I.setName("LabelTank_I"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(LabelTank_I, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                    .addComponent(ProgTank_I, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(LabelTank_I)
                .addGap(11, 11, 11)
                .addComponent(ProgTank_I, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.setBounds(90, 10, 100, 180);
        DesktopHome.add(jPanel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Sensor - Tk(II)"));
        jPanel3.setName("jPanel3"); // NOI18N

        LabelTank_II.setFont(new java.awt.Font("Tahoma", 1, 18));
        LabelTank_II.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabelTank_II.setText("3.12");
        LabelTank_II.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        LabelTank_II.setName("LabelTank_II"); // NOI18N

        ProgTank_II.setMaximum(30);
        ProgTank_II.setOrientation(1);
        ProgTank_II.setValue(15);
        ProgTank_II.setName("ProgTank_II"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(ProgTank_II, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                    .addComponent(LabelTank_II, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(LabelTank_II)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ProgTank_II, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.setBounds(200, 10, 100, 180);
        DesktopHome.add(jPanel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Controle"));
        jPanel5.setName("jPanel5"); // NOI18N

        ButtIniciar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icontrole/resources/start48.png"))); // NOI18N
        ButtIniciar.setText("Iniciar");
        ButtIniciar.setContentAreaFilled(false);
        ButtIniciar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        ButtIniciar.setName("ButtIniciar"); // NOI18N
        ButtIniciar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        ButtIniciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtIniciarActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icontrole/resources/stop-red48.png"))); // NOI18N
        jButton1.setText("Parar");
        jButton1.setContentAreaFilled(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        ButtonAtualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icontrole/resources/refresh48.png"))); // NOI18N
        ButtonAtualizar.setText("Atualizar");
        ButtonAtualizar.setContentAreaFilled(false);
        ButtonAtualizar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        ButtonAtualizar.setName("ButtonAtualizar"); // NOI18N
        ButtonAtualizar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        ButtonAtualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonAtualizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(ButtIniciar, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jButton1))
                    .addComponent(ButtonAtualizar))
                .addGap(8, 8, 8))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(ButtIniciar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ButtonAtualizar))
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel5.setBounds(310, 10, 190, 180);
        DesktopHome.add(jPanel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        JTabControle.setBackground(new java.awt.Color(255, 255, 255));
        JTabControle.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        JTabControle.setName("JTabControle"); // NOI18N

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações"));
        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setLayout(null);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Controlar");
        jLabel1.setName("jLabel1"); // NOI18N
        jPanel4.add(jLabel1);
        jLabel1.setBounds(16, 20, 53, 14);

        ComboTank.setFont(new java.awt.Font("Tahoma", 0, 14));
        ComboTank.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tank_I", "Tank_II" }));
        ComboTank.setName("ComboTank"); // NOI18N
        jPanel4.add(ComboTank);
        ComboTank.setBounds(16, 40, 104, 34);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel4.setText("Controlador");
        jLabel4.setName("jLabel4"); // NOI18N
        jPanel4.add(jLabel4);
        jLabel4.setBounds(138, 20, 67, 14);

        ComboControlador.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ComboControlador.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "P", "PI", "PD", "PID", "PI-D", "EESF", "OBES" }));
        ComboControlador.setName("ComboControlador"); // NOI18N
        jPanel4.add(ComboControlador);
        ComboControlador.setBounds(138, 40, 105, 34);

        jLabel5.setText("Parametros usados pelos Controladores");
        jLabel5.setName("jLabel5"); // NOI18N
        jPanel4.add(jLabel5);
        jLabel5.setBounds(16, 85, 191, 14);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel6.setText("(P)");
        jLabel6.setName("jLabel6"); // NOI18N
        jPanel4.add(jLabel6);
        jLabel6.setBounds(16, 111, 17, 14);

        JText_P.setFont(new java.awt.Font("Tahoma", 0, 14));
        JText_P.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        JText_P.setText("0.0");
        JText_P.setName("JText_P"); // NOI18N
        jPanel4.add(JText_P);
        JText_P.setBounds(43, 105, 105, 23);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setText("(I)");
        jLabel7.setName("jLabel7"); // NOI18N
        jPanel4.add(jLabel7);
        jLabel7.setBounds(16, 145, 15, 14);

        JText_I.setFont(new java.awt.Font("Tahoma", 0, 14));
        JText_I.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        JText_I.setText("0.0");
        JText_I.setName("JText_I"); // NOI18N
        jPanel4.add(JText_I);
        JText_I.setBounds(43, 139, 105, 23);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel8.setText("(D)");
        jLabel8.setName("jLabel8"); // NOI18N
        jPanel4.add(jLabel8);
        jLabel8.setBounds(16, 179, 18, 14);

        JText_D.setFont(new java.awt.Font("Tahoma", 0, 14));
        JText_D.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        JText_D.setText("0.0");
        JText_D.setName("JText_D"); // NOI18N
        jPanel4.add(JText_D);
        JText_D.setBounds(44, 173, 104, 23);

        Combo_I.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tempo", "Const" }));
        Combo_I.setName("Combo_I"); // NOI18N
        jPanel4.add(Combo_I);
        Combo_I.setBounds(158, 142, 85, 20);

        Combo_D.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tempo", "Const" }));
        Combo_D.setName("Combo_D"); // NOI18N
        jPanel4.add(Combo_D);
        Combo_D.setBounds(158, 176, 85, 20);

        jLabel3.setText("Tempo de Pico (s)");
        jLabel3.setName("jLabel3"); // NOI18N
        jPanel4.add(jLabel3);
        jLabel3.setBounds(259, 54, 85, 14);

        jLabel2.setText("Sobresinal (%)");
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel4.add(jLabel2);
        jLabel2.setBounds(259, 34, 71, 14);

        LabelSobresinal.setFont(new java.awt.Font("Tahoma", 1, 12));
        LabelSobresinal.setText("0.0");
        LabelSobresinal.setName("LabelSobresinal"); // NOI18N
        jPanel4.add(LabelSobresinal);
        LabelSobresinal.setBounds(374, 31, 30, 15);

        LabelTempoDePico.setFont(new java.awt.Font("Tahoma", 1, 12));
        LabelTempoDePico.setText("0.0");
        LabelTempoDePico.setName("LabelTempoDePico"); // NOI18N
        jPanel4.add(LabelTempoDePico);
        LabelTempoDePico.setBounds(374, 52, 30, 15);

        RadioCondicional.setBackground(new java.awt.Color(255, 255, 255));
        RadioCondicional.setText("Condicional");
        RadioCondicional.setName("RadioCondicional"); // NOI18N
        jPanel4.add(RadioCondicional);
        RadioCondicional.setBounds(158, 107, 79, 23);

        jLabel11.setText("Tempo de Subida (s)");
        jLabel11.setName("jLabel11"); // NOI18N
        jPanel4.add(jLabel11);
        jLabel11.setBounds(261, 74, 98, 14);

        LabelTempSubida.setFont(new java.awt.Font("Tahoma", 1, 12));
        LabelTempSubida.setText("0.0");
        LabelTempSubida.setName("LabelTempSubida"); // NOI18N
        jPanel4.add(LabelTempSubida);
        LabelTempSubida.setBounds(374, 73, 30, 15);

        jLabel12.setText("Acomodação (s)");
        jLabel12.setName("jLabel12"); // NOI18N
        jPanel4.add(jLabel12);
        jLabel12.setBounds(261, 94, 77, 14);

        LabelTempAcomodacao.setFont(new java.awt.Font("Tahoma", 1, 12));
        LabelTempAcomodacao.setText("0.0");
        LabelTempAcomodacao.setName("LabelTempAcomodacao"); // NOI18N
        jPanel4.add(LabelTempAcomodacao);
        LabelTempAcomodacao.setBounds(374, 94, 30, 15);

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel13.setText("(K0)");
        jLabel13.setName("jLabel13"); // NOI18N
        jPanel4.add(jLabel13);
        jLabel13.setBounds(261, 117, 24, 14);

        const_k0.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        const_k0.setText("0.5146");
        const_k0.setName("const_k0"); // NOI18N
        jPanel4.add(const_k0);
        const_k0.setBounds(295, 114, 69, 20);

        const_k1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        const_k1.setText("0.8771");
        const_k1.setName("const_k1"); // NOI18N
        jPanel4.add(const_k1);
        const_k1.setBounds(295, 145, 69, 20);

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel14.setText("(K1)");
        jLabel14.setName("jLabel14"); // NOI18N
        jPanel4.add(jLabel14);
        jLabel14.setBounds(261, 148, 24, 14);

        const_ki.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        const_ki.setText("0.07");
        const_ki.setName("const_ki"); // NOI18N
        jPanel4.add(const_ki);
        const_ki.setBounds(295, 176, 69, 20);

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel15.setText("(KI)");
        jLabel15.setName("jLabel15"); // NOI18N
        jPanel4.add(jLabel15);
        jLabel15.setBounds(263, 179, 22, 14);

        jTabbedPane2.setName("jTabbedPane2"); // NOI18N

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));
        jPanel7.setName("jPanel7"); // NOI18N

        jLabel16.setText("A00");
        jLabel16.setName("jlabel16"); // NOI18N

        Ad_a00.setName("Ad_a00"); // NOI18N

        jLabel17.setText("A01");
        jLabel17.setName("jLabel17"); // NOI18N

        Ad_a01.setName("Ad_a01"); // NOI18N

        Ad_a10.setName("Ad_a10"); // NOI18N

        jLabel18.setText("A10");
        jLabel18.setName("jLabel18"); // NOI18N

        jLabel19.setText("A11");
        jLabel19.setName("jLabel19"); // NOI18N

        Ad_a11.setName("Ad_a11"); // NOI18N

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(Ad_a10, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(Ad_a11, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel16)
                            .addComponent(Ad_a00, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(Ad_a01, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(35, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Ad_a01, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Ad_a00, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Ad_a11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Ad_a10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Matriz Ad", jPanel7);

        jPanel10.setBackground(new java.awt.Color(255, 255, 255));
        jPanel10.setName("jPanel10"); // NOI18N

        Bd_b0.setName("Bd_b0"); // NOI18N

        jLabel20.setText("B0");
        jLabel20.setName("jLabel20"); // NOI18N

        jLabel22.setText("B1");
        jLabel22.setName("jLabel22"); // NOI18N

        Bd_b1.setName("Bd_b1"); // NOI18N

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel22)
                    .addComponent(Bd_b1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20)
                    .addComponent(Bd_b0, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(64, 64, 64))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel20)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Bd_b0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel22)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Bd_b1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Matrix Bd", jPanel10);

        jPanel11.setBackground(new java.awt.Color(255, 255, 255));
        jPanel11.setName("jPanel11"); // NOI18N

        L_l0.setName("L_l0"); // NOI18N

        jLabel21.setText("L0");
        jLabel21.setName("jLabel21"); // NOI18N

        L_l1.setName("L_l1"); // NOI18N

        jLabel23.setText("L1");
        jLabel23.setName("jLabel23"); // NOI18N

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap(36, Short.MAX_VALUE)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel21)
                    .addComponent(L_l0, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel23)
                    .addComponent(L_l1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(L_l1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(L_l0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(64, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Ganho L", jPanel11);

        jPanel4.add(jTabbedPane2);
        jTabbedPane2.setBounds(410, 30, 190, 170);
        jTabbedPane2.getAccessibleContext().setAccessibleName("Quadro");

        JTabControle.addTab("Controladores", jPanel4);

        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
        jPanel6.setName("jPanel6"); // NOI18N

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));
        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Tensão (V)"));
        jPanel8.setName("jPanel8"); // NOI18N
        jPanel8.setLayout(new java.awt.GridLayout(1, 0));

        LabelTensao.setFont(new java.awt.Font("Tahoma", 1, 18));
        LabelTensao.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabelTensao.setText("1.0");
        LabelTensao.setName("LabelTensao"); // NOI18N
        jPanel8.add(LabelTensao);

        SlideTensao.setBackground(new java.awt.Color(255, 255, 255));
        SlideTensao.setMaximum(10);
        SlideTensao.setOrientation(javax.swing.JSlider.VERTICAL);
        SlideTensao.setPaintTicks(true);
        SlideTensao.setValue(0);
        SlideTensao.setName("SlideTensao"); // NOI18N
        SlideTensao.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SlideTensaoStateChanged(evt);
            }
        });
        jPanel8.add(SlideTensao);

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        TableTT.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Tensao", "Tempo"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Double.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        TableTT.setName("TableTT"); // NOI18N
        jScrollPane1.setViewportView(TableTT);

        jLabel9.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel9.setText("Ajuste das Constantes");
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel10.setText("Const_I :");
        jLabel10.setName("jLabel10"); // NOI18N

        LabelConst_I.setBackground(new java.awt.Color(255, 255, 255));
        LabelConst_I.setFont(new java.awt.Font("Tahoma", 1, 14));
        LabelConst_I.setForeground(new java.awt.Color(51, 102, 255));
        LabelConst_I.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabelConst_I.setText("0.0");
        LabelConst_I.setName("LabelConst_I"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(15, 15, 15)
                        .addComponent(LabelConst_I, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)))
                .addGap(193, 193, 193))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(LabelConst_I)))
                    .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                        .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        JTabControle.addTab("Sistema de Tanques", jPanel6);

        JTabControle.setBounds(10, 200, 610, 250);
        DesktopHome.add(JTabControle, javax.swing.JLayeredPane.DEFAULT_LAYER);
        JTabControle.getAccessibleContext().setAccessibleName("TabControles");

        _plotALL.setBackground(new java.awt.Color(255, 255, 255));
        _plotALL.setBorder(javax.swing.BorderFactory.createTitledBorder("Grafico"));
        _plotALL.setName("_plotALL"); // NOI18N

        javax.swing.GroupLayout _plotALLLayout = new javax.swing.GroupLayout(_plotALL);
        _plotALL.setLayout(_plotALLLayout);
        _plotALLLayout.setHorizontalGroup(
            _plotALLLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 528, Short.MAX_VALUE)
        );
        _plotALLLayout.setVerticalGroup(
            _plotALLLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 413, Short.MAX_VALUE)
        );

        _plotALL.setBounds(620, 10, 540, 440);
        DesktopHome.add(_plotALL, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        ChartTank_I.setBackground(new java.awt.Color(255, 255, 255));
        ChartTank_I.setName("ChartTank_I"); // NOI18N

        ChartOne.setName("ChartOne"); // NOI18N

        javax.swing.GroupLayout ChartOneLayout = new javax.swing.GroupLayout(ChartOne);
        ChartOne.setLayout(ChartOneLayout);
        ChartOneLayout.setHorizontalGroup(
            ChartOneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1145, Short.MAX_VALUE)
        );
        ChartOneLayout.setVerticalGroup(
            ChartOneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 172, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout ChartTank_ILayout = new javax.swing.GroupLayout(ChartTank_I);
        ChartTank_I.setLayout(ChartTank_ILayout);
        ChartTank_ILayout.setHorizontalGroup(
            ChartTank_ILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartOne, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        ChartTank_ILayout.setVerticalGroup(
            ChartTank_ILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartOne, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Analise [ Tank - I ]", ChartTank_I);

        ChartTank_II.setBackground(new java.awt.Color(255, 255, 255));
        ChartTank_II.setName("ChartTank_II"); // NOI18N

        ChartTwo.setBackground(new java.awt.Color(255, 255, 255));
        ChartTwo.setName("ChartTwo"); // NOI18N

        javax.swing.GroupLayout ChartTwoLayout = new javax.swing.GroupLayout(ChartTwo);
        ChartTwo.setLayout(ChartTwoLayout);
        ChartTwoLayout.setHorizontalGroup(
            ChartTwoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1145, Short.MAX_VALUE)
        );
        ChartTwoLayout.setVerticalGroup(
            ChartTwoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 172, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout ChartTank_IILayout = new javax.swing.GroupLayout(ChartTank_II);
        ChartTank_II.setLayout(ChartTank_IILayout);
        ChartTank_IILayout.setHorizontalGroup(
            ChartTank_IILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartTwo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        ChartTank_IILayout.setVerticalGroup(
            ChartTank_IILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartTwo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Analise [ Tank - II ]", ChartTank_II);

        ChartSinalControle.setBackground(new java.awt.Color(255, 255, 255));
        ChartSinalControle.setName("ChartSinalControle"); // NOI18N

        ChartSControle.setBackground(new java.awt.Color(255, 255, 255));
        ChartSControle.setName("ChartSControle"); // NOI18N

        javax.swing.GroupLayout ChartSControleLayout = new javax.swing.GroupLayout(ChartSControle);
        ChartSControle.setLayout(ChartSControleLayout);
        ChartSControleLayout.setHorizontalGroup(
            ChartSControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1145, Short.MAX_VALUE)
        );
        ChartSControleLayout.setVerticalGroup(
            ChartSControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 172, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout ChartSinalControleLayout = new javax.swing.GroupLayout(ChartSinalControle);
        ChartSinalControle.setLayout(ChartSinalControleLayout);
        ChartSinalControleLayout.setHorizontalGroup(
            ChartSinalControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartSControle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        ChartSinalControleLayout.setVerticalGroup(
            ChartSinalControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartSControle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Analise [ Sinal de Controle ]", ChartSinalControle);

        jPanel9.setBackground(new java.awt.Color(255, 255, 255));
        jPanel9.setName("jPanel9"); // NOI18N

        ChartErro.setBackground(new java.awt.Color(255, 255, 255));
        ChartErro.setName("ChartErro"); // NOI18N

        javax.swing.GroupLayout ChartErroLayout = new javax.swing.GroupLayout(ChartErro);
        ChartErro.setLayout(ChartErroLayout);
        ChartErroLayout.setHorizontalGroup(
            ChartErroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1145, Short.MAX_VALUE)
        );
        ChartErroLayout.setVerticalGroup(
            ChartErroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 172, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartErro, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ChartErro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Analise [ Erro ]", jPanel9);

        jTabbedPane1.setBounds(10, 470, 1150, 200);
        DesktopHome.add(jTabbedPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(DesktopHome, javax.swing.GroupLayout.DEFAULT_SIZE, 1165, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(DesktopHome, javax.swing.GroupLayout.PREFERRED_SIZE, 685, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        menuBar.setBackground(new java.awt.Color(204, 204, 204));
        menuBar.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        menuBar.setBorderPainted(false);
        menuBar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        menuBar.setName("menuBar"); // NOI18N
        menuBar.setPreferredSize(new java.awt.Dimension(295, 30));

        fileMenu.setBorder(null);
        fileMenu.setText("Arquivo");
        fileMenu.setFont(new java.awt.Font("Segoe UI", 1, 12));
        fileMenu.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        fileMenu.setName("fileMenu"); // NOI18N
        fileMenu.setPreferredSize(new java.awt.Dimension(64, 80));
        fileMenu.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        Button_Abrir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        Button_Abrir.setText("Abrir");
        Button_Abrir.setName("Button_Abrir"); // NOI18N
        Button_Abrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_AbrirActionPerformed(evt);
            }
        });
        fileMenu.add(Button_Abrir);

        ButtonSalvar.setText("Salvar");
        ButtonSalvar.setName("ButtonSalvar"); // NOI18N
        ButtonSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonSalvarActionPerformed(evt);
            }
        });
        fileMenu.add(ButtonSalvar);

        Button_Salvar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        Button_Salvar.setText("Salvar como...");
        Button_Salvar.setName("Button_Salvar"); // NOI18N
        Button_Salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_SalvarActionPerformed(evt);
            }
        });
        fileMenu.add(Button_Salvar);

        ButtonPrint.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        ButtonPrint.setText("Imprimir...");
        ButtonPrint.setName("ButtonPrint"); // NOI18N
        fileMenu.add(ButtonPrint);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(icontrole.IControleApp.class).getContext().getActionMap(IControleView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        MenuExp.setText("Experiencia");
        MenuExp.setFont(new java.awt.Font("Segoe UI", 1, 12));
        MenuExp.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        MenuExp.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        MenuExp.setName("MenuExp"); // NOI18N
        MenuExp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        menuBar.add(MenuExp);

        MenuConfig.setBorder(null);
        MenuConfig.setText("Configurações");
        MenuConfig.setFont(new java.awt.Font("Segoe UI", 1, 12));
        MenuConfig.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        MenuConfig.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        MenuConfig.setMaximumSize(new java.awt.Dimension(100, 32767));
        MenuConfig.setName("MenuConfig"); // NOI18N
        MenuConfig.setPreferredSize(new java.awt.Dimension(100, 64));
        MenuConfig.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        ButtonQuanser.setText("ClienteQuanser");
        ButtonQuanser.setName("ButtonQuanser"); // NOI18N
        ButtonQuanser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonQuanserActionPerformed(evt);
            }
        });
        MenuConfig.add(ButtonQuanser);

        menuBar.add(MenuConfig);

        statusPanel.setBackground(new java.awt.Color(255, 255, 255));
        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 1175, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 1005, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void ButtonQuanserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonQuanserActionPerformed


        this._quanserconfig.setVisible(true);
        this.DesktopHome.remove(this._quanserconfig);
        this.DesktopHome.add(this._quanserconfig);
        try {

            this._quanserconfig.setSelected(true);
        } catch (Exception e) {
        }

        // TODO add your handling code here:
    }//GEN-LAST:event_ButtonQuanserActionPerformed

    private void Button_SalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_SalvarActionPerformed
        JFileChooser eleitor = new JFileChooser();
        eleitor.setCurrentDirectory(new File("."));

        int result = eleitor.showSaveDialog(null);
        if (result == JFileChooser.APPROVE_OPTION) {
            File arquivo = eleitor.getSelectedFile();
            String path = arquivo.getPath();
            _export.Save(path);

        }

        // TODO add your handling code here:
    }//GEN-LAST:event_Button_SalvarActionPerformed

    private void Button_AbrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_AbrirActionPerformed
        JFileChooser eleitor = new JFileChooser();
        eleitor.setCurrentDirectory(new File("."));

        int result = eleitor.showOpenDialog(null);
        if (result == JFileChooser.APPROVE_OPTION) {
            File arquivo = eleitor.getSelectedFile();
            String path = arquivo.getPath();
            boolean Load = _export.Load(path);
            if (Load == false) {
                JOptionPane.showMessageDialog(this.mainPanel, "Não foi possivel carregar o arquivo de configuraçao!");
            } else {
                this.SetNivel(this._server.getNivel());
            }

        }

        // TODO add your handling code here:
    }//GEN-LAST:event_Button_AbrirActionPerformed

    private void SlideNivelStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SlideNivelStateChanged
        Integer value = SlideNivel.getValue();
        this.LabelNivel.setText(value.toString());
        this._server.setNivel(value.toString());
        // TODO add your handling code here:
    }//GEN-LAST:event_SlideNivelStateChanged

    private void ButtonSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonSalvarActionPerformed
        _export.Save();
        // TODO add your handling code here:
    }//GEN-LAST:event_ButtonSalvarActionPerformed

    private void ButtonAtualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonAtualizarActionPerformed
        selectedIndex = this.JTabControle.getSelectedIndex();
        Atualizar(selectedIndex);


    }//GEN-LAST:event_ButtonAtualizarActionPerformed
    private void Atualizar(int index) {
        double nivel_ = Double.parseDouble(this.SlideNivel.getValue() + ".0");
        count = 0;
        ((Plot) _plotALL).Clear();

        switch (index) {
            case 0:
                int tank_ = this.ComboTank.getSelectedIndex();
                int controlador_ = this.ComboControlador.getSelectedIndex();
                double kp_ = Double.parseDouble(this.JText_P.getText());
                double ki_ = Double.parseDouble(this.JText_I.getText());
                double kd_ = Double.parseDouble(this.JText_D.getText());
                double cst_k0_ = Double.parseDouble(this.const_k0.getText());
                double cst_k1_ = Double.parseDouble(this.const_k1.getText());
                double cst_ki_ = Double.parseDouble(this.const_ki.getText());
                int tipo_I = Combo_I.getSelectedIndex();
                int tipo_D = Combo_D.getSelectedIndex();
                if (this.RadioCondicional.isSelected()) {
                    _centro.getControlador().setCondicional(true);
                } else {
                    _centro.getControlador().setCondicional(false);
                }
                Integer value = SlideNivel.getValue();
                this._server.setNivel(value.toString());
                this._centro.setSearching(true);
                this._centro.setFalgTr(true);
                this._centro.setFalgTs(true);
                //Controlador EESF
                if (controlador_ == 5) {
                    _centro.repassarParametros(nivel_, controlador_, tank_, cst_k0_, cst_k1_, cst_ki_, false);
                } else {
                    if (controlador_ == 6) {
                       double[] Ml = {Util.Parse( this.L_l0.getText()), Util.Parse(this.L_l1.getText())};
                       double [] Ad = {Util.Parse(this.Ad_a00.getText()),Util.Parse(this.Ad_a01.getText()),Util.Parse(this.Ad_a10.getText()),Util.Parse(this.Ad_a11.getText())};
                       double [] Bd = {Util.Parse(this.Bd_b0.getText()),Util.Parse(this.Bd_b1.getText())};
                     _centro.repassarParametros(nivel_, controlador_, tank_, cst_k0_, cst_k1_, cst_ki_,Ad,Bd,Ml, false);
                    } else {
                        _centro.repassarParametros(nivel_, controlador_, kp_, ki_, kd_, tank_, tipo_I, tipo_D, false);

                    }
                }

                break;
            case 1:
                this.state = true;
                Double tensao = Double.parseDouble(this.LabelTensao.getText());
                _centro.ExpOne(tensao, nivel_, true);
                break;
        }
    }
    private void ButtIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtIniciarActionPerformed
        this._server.StartServer();
        this.ButtIniciar.setEnabled(false);


        // TODO add your handling code here:
    }//GEN-LAST:event_ButtIniciarActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            _centro.repassarParametros(0.0, 0, 0.0, 0.0, 0.0, 0, 0, 0, false);
            this._server.StopServer();
            this.count = 0;
            this._centro.setSearching(true);


        } catch (InterruptedException ex) {
            Logger.getLogger(IControleView.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.ButtIniciar.setEnabled(true);

    }//GEN-LAST:event_jButton1ActionPerformed

    private void SlideTensaoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SlideTensaoStateChanged
        Integer value = this.SlideTensao.getValue();
        Double get = this._util.getHasmap().get(value);
        this.LabelTensao.setText(this._server.enxuga(get).toString());
        // TODO add your handling code here:
    }//GEN-LAST:event_SlideTensaoStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField Ad_a00;
    private javax.swing.JTextField Ad_a01;
    private javax.swing.JTextField Ad_a10;
    private javax.swing.JTextField Ad_a11;
    private javax.swing.JTextField Bd_b0;
    private javax.swing.JTextField Bd_b1;
    private javax.swing.JButton ButtIniciar;
    private javax.swing.JButton ButtonAtualizar;
    private javax.swing.JMenuItem ButtonPrint;
    private javax.swing.JMenuItem ButtonQuanser;
    private javax.swing.JMenuItem ButtonSalvar;
    private javax.swing.JMenuItem Button_Abrir;
    private javax.swing.JMenuItem Button_Salvar;
    private javax.swing.JPanel ChartErro;
    private javax.swing.JPanel ChartOne;
    private javax.swing.JPanel ChartSControle;
    private javax.swing.JPanel ChartSinalControle;
    private javax.swing.JPanel ChartTank_I;
    private javax.swing.JPanel ChartTank_II;
    private javax.swing.JPanel ChartTwo;
    private javax.swing.JComboBox ComboControlador;
    private javax.swing.JComboBox ComboTank;
    private javax.swing.JComboBox Combo_D;
    private javax.swing.JComboBox Combo_I;
    private javax.swing.JDesktopPane DesktopHome;
    private javax.swing.JTabbedPane JTabControle;
    private javax.swing.JTextField JText_D;
    private javax.swing.JTextField JText_I;
    private javax.swing.JTextField JText_P;
    private javax.swing.JTextField L_l0;
    private javax.swing.JTextField L_l1;
    private javax.swing.JLabel LabelConst_I;
    private javax.swing.JLabel LabelNivel;
    private javax.swing.JLabel LabelSobresinal;
    private javax.swing.JLabel LabelTank_I;
    private javax.swing.JLabel LabelTank_II;
    private javax.swing.JLabel LabelTempAcomodacao;
    private javax.swing.JLabel LabelTempSubida;
    private javax.swing.JLabel LabelTempoDePico;
    private javax.swing.JLabel LabelTensao;
    private javax.swing.JMenu MenuConfig;
    private javax.swing.JMenu MenuExp;
    private javax.swing.JProgressBar ProgTank_I;
    private javax.swing.JProgressBar ProgTank_II;
    private javax.swing.JRadioButton RadioCondicional;
    private javax.swing.JSlider SlideNivel;
    private javax.swing.JSlider SlideTensao;
    private javax.swing.JTable TableTT;
    private javax.swing.JPanel _plotALL;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JTextField const_k0;
    private javax.swing.JTextField const_k1;
    private javax.swing.JTextField const_ki;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;

    private void SetNivel(String nivel) {
        if (!"".equals(nivel) && nivel != null) {
            this.LabelNivel.setText(nivel);
            this.SlideNivel.setValue(Integer.parseInt(nivel));
        }

    }

    public void update(Observable o, Object arg) {

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                UpdateSelect(selectedIndex);
            }
        });

    }

    private void UpdateSelect(int index) {
        double nivel_ = Double.parseDouble(this.SlideNivel.getValue() + ".0");
        int tank_ = this.ComboTank.getSelectedIndex();
        Double nivel_tk1 = _server.getNivel_tk1();
        Double nivel_tk2 = _server.getNivel_tk2();
        LabelTank_I.setText(nivel_tk1.toString());
        LabelTank_II.setText(nivel_tk2.toString());
        ProgTank_I.setValue((int) Math.round(nivel_tk1));
        ProgTank_II.setValue((int) Math.round(nivel_tk2));
        ++count;
        _xytank_I.add(TransSeg(count), nivel_tk1);
        _xytank_II.add(TransSeg(count), nivel_tk2);
        switch (index) {
            case 0:
                _xyerro.add(TransSeg(count), _server.getSinalErro());
                _xyscontrol.add(TransSeg(count), _server.tensaoLimitada(_server.getSinalControle()));
                _centro.setCount(count);
                if (tank_ == 0) {
                    LabelSobresinal.setText(Util.ShowSobreSinal(_xytank_I, nivel_));
                    LabelTempoDePico.setText(Util.ShowTempoDePico(_xytank_I, nivel_));
                } else {
                    LabelSobresinal.setText(Util.ShowSobreSinal(_xytank_II, nivel_));
                    LabelTempoDePico.setText(Util.ShowTempoDePico(_xytank_II, nivel_));
                }

                LabelTempSubida.setText(_server.showTempoSubida());
                LabelTempAcomodacao.setText(_server.showTempoAcomodacao());
                break;
            case 1:

                String tensao = this.LabelTensao.getText();
                if (nivel_ <= nivel_tk1 && state) {
                    TableTT.setValueAt(tensao, _line, 0);
                    TableTT.setValueAt(count + 1, _line, 1);
                    _line++;
                    state = false;
                    _server.parar();
                }

                break;
        }

    }

    public ServerQuanser getServer() {
        return _server;
    }

    public void setServer(ServerQuanser _server) {
        this._server = _server;
    }

    public Centro getCentro() {
        return _centro;
    }

    public void setCentro(Centro _centro) {
        this._centro = _centro;
    }

    public double TransSeg(int value) {
        return value * 0.1;
    }
}
